﻿--
-- Dropping stored procedure pr_KhachHang_SelectAll : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_KhachHang_SelectAll]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_KhachHang_SelectAll]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_KhachHang_SelectAll
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:17 PM
-- Description:	This stored procedure is intended for selecting all rows from KhachHang table
-- ==========================================================================================
Create Procedure pr_KhachHang_SelectAll
As
Begin
	Select 
		[MaKH],
		[TenKH],
		[DiaChi],
		[SDT]
	From KhachHang
End

GO


--
-- Dropping stored procedure pr_KhachHang_SelectRow : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_KhachHang_SelectRow]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_KhachHang_SelectRow]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_KhachHang_SelectRow
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:17 PM
-- Description:	This stored procedure is intended for selecting a specific row from KhachHang table
-- ==========================================================================================
Create Procedure pr_KhachHang_SelectRow
	@MaKH varchar(10)
As
Begin
	Select 
		[MaKH],
		[TenKH],
		[DiaChi],
		[SDT]
	From KhachHang
	Where
		[MaKH] = @MaKH
End

GO


--
-- Dropping stored procedure pr_KhachHang_Insert : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_KhachHang_Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_KhachHang_Insert]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_KhachHang_Insert
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:17 PM
-- Description:	This stored procedure is intended for inserting values to KhachHang table
-- ==========================================================================================
Create Procedure pr_KhachHang_Insert
	@MaKH varchar(10),
	@TenKH nvarchar(50),
	@DiaChi nvarchar(200),
	@SDT varchar(50)
As
Begin
	Insert Into KhachHang
		([MaKH],[TenKH],[DiaChi],[SDT])
	Values
		(@MaKH,@TenKH,@DiaChi,@SDT)

End

GO


--
-- Dropping stored procedure pr_KhachHang_Update : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_KhachHang_Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_KhachHang_Update]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_KhachHang_Update
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:17 PM
-- Description:	This stored procedure is intended for updating KhachHang table
-- ==========================================================================================
Create Procedure pr_KhachHang_Update
	@MaKH varchar(10),
	@TenKH nvarchar(50),
	@DiaChi nvarchar(200),
	@SDT varchar(50)
As
Begin
	Update KhachHang
	Set
		[TenKH] = @TenKH,
		[DiaChi] = @DiaChi,
		[SDT] = @SDT
	Where		
		[MaKH] = @MaKH

End

GO


--
-- Dropping stored procedure pr_KhachHang_DeleteRow : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_KhachHang_DeleteRow]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_KhachHang_DeleteRow]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_KhachHang_DeleteRow
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:17 PM
-- Description:	This stored procedure is intended for deleting a specific row from KhachHang table
-- ==========================================================================================
Create Procedure pr_KhachHang_DeleteRow
	@MaKH varchar(10)
As
Begin
	Delete KhachHang
	Where
		[MaKH] = @MaKH

End

GO
